package com.alliky.user.ui.viewmodel;

import android.app.Application;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.alliky.core.base.BaseViewModel;
import com.alliky.core.binding.command.BindingCommand;
import com.alliky.core.bus.RxBus;

/**
 * @Description TODO
 * @Author wxianing
 * @Date 2020-11-15
 */
public class UserDetailViewModel extends BaseViewModel {

    public ObservableField<String> nameObservable = new ObservableField();

    public UserDetailViewModel(@NonNull Application application) {
        super(application);
    }

    public void setName(String name) {
        nameObservable.set(name);
    }

    //回传参数
    public BindingCommand backOnClickCommand = new BindingCommand(() -> {
        if (!TextUtils.isEmpty(nameObservable.get())) {
            //RxBus解耦组件通信
            RxBus.getDefault().post(nameObservable.get());
        }
        finish();
    });
}
